<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one or more
  ~ contributor license agreements.  See the NOTICE file distributed with
  ~ this work for additional information regarding copyright ownership.
  ~ The ASF licenses this file to You under the Apache License, Version 2.0
  ~ (the "License"); you may not use this file except in compliance with
  ~ the License.  You may obtain a copy of the License at
  ~
  ~    http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  ~
  -->

<sp-visualization-config-outer
    [configurationValid]="
        currentlyConfiguredWidget.visualizationConfig.configurationValid
    "
>
    <div fxLayout="column">
        <sp-configuration-box title="Fields">
            <div fxLayout="column" fxLayoutGap="10px">
                <div
                    fxLayout="row"
                    fxFlex="100"
                    fxLayoutGap="10px"
                    fxLayoutAlign="start center"
                >
                    <small fxFlex="30">Latitude</small>
                    <sp-select-property
                        fxFlex
                        [availableProperties]="fieldProvider.numericFields"
                        [selectedProperty]="
                            currentlyConfiguredWidget.visualizationConfig
                                .selectedLatitudeProperty
                        "
                        (changeSelectedProperty)="
                            setSelectedLatitudeProperty($event)
                        "
                        data-cy="data-view-map-select-latitude"
                    >
                    </sp-select-property>
                </div>
                <div
                    fxLayout="row"
                    fxFlex="100"
                    fxLayoutGap="10px"
                    fxLayoutAlign="start center"
                >
                    <small fxFlex="30">Longitude</small>
                    <sp-select-property
                        fxFlex
                        [availableProperties]="fieldProvider.numericFields"
                        [selectedProperty]="
                            currentlyConfiguredWidget.visualizationConfig
                                .selectedLongitudeProperty
                        "
                        (changeSelectedProperty)="
                            setSelectedLongitudeProperty($event)
                        "
                        data-cy="data-view-map-select-longitude"
                    >
                    </sp-select-property>
                </div>
            </div>
        </sp-configuration-box>
        <sp-configuration-box title="Settings">
            <div fxLayout="column" fxLayoutGap="10px">
                <div
                    fxLayout="row"
                    fxLayoutGap="10px"
                    fxLayoutAlign="start center"
                    fxFlex="100"
                >
                    <small fxFlex="30">Map Zoom</small>
                    <mat-form-field color="accent" appearance="outline" fxFlex>
                        <mat-label> <span>enter zoom value</span></mat-label>
                        <input
                            [(ngModel)]="
                                currentlyConfiguredWidget.visualizationConfig
                                    .selectedZoomValue
                            "
                            matInput
                            (input)="setZoomValue($event.target.value)"
                        />
                    </mat-form-field>
                </div>

                <div
                    fxLayout="row"
                    fxLayoutGap="10px"
                    fxLayoutAlign="start center"
                    fxFlex="100"
                >
                    <mat-checkbox
                        [(ngModel)]="
                            currentlyConfiguredWidget.visualizationConfig
                                .useLastEventCoordinates
                        "
                        (change)="setUseLastEventCoordinations($event)"
                        >Focus map on last event
                    </mat-checkbox>
                </div>

                <div
                    fxLayout="row"
                    fxLayoutGap="10px"
                    fxLayoutAlign="start center"
                    fxFlex="100"
                >
                    <small fxFlex="30">Marker or Trace</small>
                    <mat-form-field color="accent" appearance="outline" fxFlex>
                        <!-- <mat-label>Marker or Trace</mat-label> -->
                        <mat-select
                            [(value)]="
                                currentlyConfiguredWidget.visualizationConfig
                                    .selectedMarkerOrTrace
                            "
                            (selectionChange)="triggerViewRefresh()"
                            data-cy="data-view-map-select-marker-or-trace"
                        >
                            <mat-option [value]="'marker'">Marker</mat-option>
                            <mat-option [value]="'trace'">Trace</mat-option>
                        </mat-select>
                    </mat-form-field>
                </div>

                <div
                    fxLayout="row"
                    fxLayoutGap="10px"
                    fxLayoutAlign="start center"
                    fxFlex="100"
                    *ngIf="
                        currentlyConfiguredWidget.visualizationConfig
                            .selectedMarkerOrTrace === 'marker'
                    "
                >
                    <small fxFlex="30">Marker Type</small>
                    <mat-form-field fxFlex color="accent" appearance="outline">
                        <mat-select
                            [(value)]="
                                currentlyConfiguredWidget.visualizationConfig
                                    .selectedMarkerType
                            "
                            (selectionChange)="triggerViewRefresh()"
                        >
                            <mat-option [value]="'pin'">Pin</mat-option>
                            <mat-option [value]="'car'">Car</mat-option>
                        </mat-select>
                    </mat-form-field>
                </div>
            </div>
        </sp-configuration-box>

        <sp-select-properties
            title="Tooltip"
            label="Tooltip Content"
            multiple="true"
            (changeSelectedProperties)="setSelectedToolTipContent($event)"
            [availableProperties]="fieldProvider.allFields"
            [selectedProperties]="
                currentlyConfiguredWidget.visualizationConfig
                    .selectedToolTipContent
            "
            *ngIf="
                currentlyConfiguredWidget.visualizationConfig
                    .selectedMarkerOrTrace === 'marker'
            "
        >
        </sp-select-properties>
    </div>
</sp-visualization-config-outer>
